//
//  XLGHTTPProtocolBase.m
//  etionCBLogic
//
//  Created by wjxfhxy on 15-4-10.
//  Copyright (c) 2015年 GuangZhouXuanWu. All rights reserved.
//

#import "XLGHTTPProtocolBase.h"

#import "ProtocolHTTPSREST.h"

@implementation XLGHTTPProtocolBase

- (id)init
{
    self = [super init];
    
    self->_transformType = EProtocolTransformTypeHTTPSREST;
    
    return self;
}

- (void)writeHTTPSREEST:(CProtocolHTTPSREST *)phr
{
    writeRequestProtocolBlock protocol=^(NSString *URI,XLGHTTPMethodType method,requestProtocolHead requestHeadBlock,NSDictionary *jsonDictionary,NSData *jsonData)
    {
        if(requestHeadBlock != NULL)
        {
            NSDictionary *requestHead = requestHeadBlock(phr.requestHead);
            if(requestHead != nil)
                [phr.requestHead setDictionary:requestHead];
        }
        
        phr.URI = URI;
        
        phr.HTTPRESTMethod = method;
        
        if(jsonDictionary != nil)
            phr.body = [NSJSONSerialization dataWithJSONObject:jsonDictionary options:NSJSONWritingPrettyPrinted error:nil];
        else if(jsonData != nil)
            phr.body = jsonData;
        else
            phr.body = nil;
    };
    
    [self writeRequestProtocol:protocol];
}

- (void)writeRequestProtocol:(writeRequestProtocolBlock)protocol
{
}

-(void)readHTTPSREEST:(CProtocolHTTPSREST *)phr output:(NSObject **)obj
{
    NSDictionary *dic = [super readHTTPSREEST:phr];
    if(dic != nil)
    {
        [self readResponseProtocol:dic output:obj];
    }
}

- (void)readResponseProtocol:(NSDictionary *)jsonDictionary output:(NSObject **)obj
{
    
}

@end
